package com.example.testdemo.spring.config;

import com.example.testdemo.annotation.Component;
import com.example.testdemo.expection.BeansException;
import com.example.testdemo.spring.ApplicationContext;

/**
 * <p>
 * 拿到上下文对象 可以做一个Bean工厂
 * </p>
 *
 * @author 永健
 * @since 2020-03-29 03:39
 */
@Component
public class MyApplicationContextAware implements ApplicationContextAware {
    public static ApplicationContext context;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context=applicationContext;
        System.out.println("拿到Spring上上下文对象");
        System.out.println(context);
    }
    public static ApplicationContext getApplicationContext() {
        return context;
    }
}
